/*
题目链接:

https://leetcode.cn/problems/fruits-into-baskets-ii/?slug=maximize-subarrays-after-removing-one-conflicting-pair&tab=solutions&tab=3603047&tab=mei-ju-zuo-duan-dian-wei-hu-zui-xiao-ci-4nvu6&region=local_v2
*/

//题解代码:
class Solution {
public:
    int numOfUnplacedFruits(vector<int>& fruits, vector<int>& baskets) {
        int n = fruits.size();
        vector<int> vis(n,0);
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                if(vis[j]==0 && baskets[j]>=fruits[i]){
                    vis[j] = 1;
                    break;
                }
            }
        }
        int ans = 0;
        for(int i=0;i<n;++i) ans += vis[i]==0;
        return ans;
    }
};
